package com.jdz.controller.portal;

import com.jdz.common.Const;
import com.jdz.common.ResponseCode;
import com.jdz.common.ServerResponse;
import com.jdz.pojo.Announcemen;
import com.jdz.service.IAnnouncemenService;
import com.jdz.service.IUserService;

import com.jdz.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


/**
 * Created by sun
 **/
@Controller
@RequestMapping("/announcemen")
public class AnnouncemenController {

    @Autowired
    IUserService iUserService;

    @Autowired
    IAnnouncemenService iAnnouncemenService;


    /**
     *公告列表
     * @param pageNum
     * @param pageSize
     * @param startTime
     * @param stopTime
     * @return
     */
    @RequestMapping(value = "list_announcemen.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse listAnnouncemen(@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,
                                          @RequestParam(value = "pageSize",defaultValue = "5")int pageSize,@RequestParam(value = "name",required = false) String name,@RequestParam(value = "startTime",required = false)String startTime,
                                          @RequestParam(value = "stopTime",required = false)String stopTime,@RequestParam(value = "time_sort",defaultValue = "0") int time_sort) {
        return iAnnouncemenService.listUserAnnouncemen(pageNum,pageSize,name,startTime,stopTime,time_sort);
    }



    /**
     * 公告详情
     * @param annno
     * @return
     */
    @RequestMapping(value = "details_announcemenn.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse  detailsAnnouncemen(Integer  annno) {
        return iAnnouncemenService.detailsAnnouncemen(annno);
    }


    /**
     *首页搜索接口
     * @param session
     * @return
     */
    @RequestMapping(value = "search_index.do",method = RequestMethod.GET)
    @ResponseBody
    public ServerResponse search_index(HttpSession session,@RequestParam(value = "name",required = false) String name) throws Exception {
        return iAnnouncemenService.search_index(name);
    }


}
